package com.starlink.client.jd.request;

import com.lop.open.api.sdk.domain.ECAP.CommonModifyCancelOrderApi.commonCancelOrderV1.CommonOrderCancelRequest;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 取消订单入参模型
 * 传参规则详情见京东文档
 * <a href="https://open.jdl.com/#/open-business-document/api-doc/267/846"/>
 */
@Data
@NoArgsConstructor
public class CancelOrderRequest implements Serializable {
    /**
     * 京东物流运单号，运单号在下单接口中已返回，同京东运单号、商家订单号必填其一
     */
    private String waybillCode;
    /**
     * 京东物流订单号，订单号在下单接口中已返回，同京东运单号、商家订单号必填其一
     */
    private String orderCode;
    /**
     * 商家订单号，商家下单时传入，同京东运单号、京东订单号必填其一
     */
    private String customerOrderId;
    /**
     * 下单来源：0-c2c；1-b2c；2-c2b；与下单接口入参保持一致
     */
    private Integer orderOrigin;
    /**
     * 客户编码，orderOrigin=1 时必填；与下单时使用的客户编码保持一致
     */
    private String customerCode;
    /**
     * 取消原因，商家自定义，字段长度1-30
     */
    private String cancelReason;
    /**
     * 取消原因编码；枚举值：1-用户发起取消；2-超时未支付
     */
    private String cancelReasonCode;
    /**
     * 枚举值：0：仅取消；1：优先取消，取消失败后拦截；2：仅发起拦截
     */
    private Integer cancelType;

    /**
     * 模型转换
     * @return
     */
    public CommonOrderCancelRequest toJdCancel() {
        CommonOrderCancelRequest request = new CommonOrderCancelRequest();
        request.setWaybillCode(this.waybillCode);
        request.setOrderCode(this.orderCode);
        request.setCustomerCode(this.customerOrderId);
        request.setOrderOrigin(this.orderOrigin);
        request.setCustomerCode(this.customerCode);
        request.setCancelReason(this.cancelReason);
        request.setCancelReasonCode(this.cancelReasonCode);
        request.setCancelType(this.cancelType);
        return request;
    }
}
